home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F19186_EmpElemTextBoxPull1.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.6 KB  |  66 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       HTML
  4.   Sub-category:   TextBox
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This series of textboxes is generated using the pull method
  10.     of extracting xml elements. Each element will generate a
  11.     text box. Also note that we are using the Pull method to
  12.     extract data from our xml document.  The pull method is an
  13.     approach where the use of templates is minimized and data
  14.     is accessed by 'pulling' it from our xml document
  15. ================================================================ -->
  16. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  17.   <xsl:output method="html" />
  18.  
  19.   <xsl:template match="/">
  20.     <html>
  21.       <head>
  22.         <style type="text/css">
  23.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  24.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  25.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  26.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  27.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  28.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  29.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  30.         TR { background-color: beige; }
  31.         BODY { background-color: beige; }
  32.         </style>
  33.       </head>
  34.       <body>
  35.         <h1>Generating a text box from xml (Pull Method)</h1>
  36.         <xsl:for-each select="/employees/employee">
  37.           <!-- The following for-each loop will iterate through all of the child elements
  38.                of employee -->
  39.           <xsl:for-each select="*">
  40.             <xsl:value-of select="name(.)" />
  41.  
  42.             <xsl:element name="Input">
  43.               <!-- Set the Size of the textbox -->
  44.               <xsl:attribute name="size">
  45.                 <xsl:value-of select="string-length(.)" />
  46.               </xsl:attribute>
  47.  
  48.               <!-- Set the Size of the textbox -->
  49.               <xsl:attribute name="maxlength">
  50.                 <xsl:value-of select="string-length(.) + 5" />
  51.               </xsl:attribute>
  52.  
  53.               <!-- Set the value of the text box -->
  54.               <xsl:attribute name="value">
  55.                 <xsl:value-of select="text()" />
  56.               </xsl:attribute>
  57.  
  58.               <br />
  59.             </xsl:element>
  60.           </xsl:for-each>
  61.         </xsl:for-each>
  62.       </body>
  63.     </html>
  64.   </xsl:template>
  65. </xsl:stylesheet>
  66.